﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：S_UPLOAD_LOG实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class S_UPLOAD_LOG
    {

        private decimal m_dec_id;
        /// <summary>
        /// 主键
        /// </summary>
        public decimal ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private decimal? m_dec_i_type;
        /// <summary>
        /// 材料类别 1用水2取水
        /// </summary>
        public decimal? I_TYPE { get { return m_dec_i_type; } set { m_dec_i_type = value; } }

        private string m_str_s_wenjianlj;
        /// <summary>
        /// 文件链接地址
        /// </summary>
        public string S_WENJIANLJ { get { return m_str_s_wenjianlj; } set { m_str_s_wenjianlj = value; } }

        private decimal? m_dec_i_wenjianlx;
        /// <summary>
        /// 文件类型
        /// </summary>
        public decimal? I_WENJIANLX { get { return m_dec_i_wenjianlx; } set { m_dec_i_wenjianlx = value; } }

        private string m_str_s_wenjianmc;
        /// <summary>
        /// 文件名称
        /// </summary>
        public string S_WENJIANMC { get { return m_str_s_wenjianmc; } set { m_str_s_wenjianmc = value; } }

        private string m_str_s_yonghubh;
        /// <summary>
        /// 用户编号
        /// </summary>
        public string S_YONGHUBH { get { return m_str_s_yonghubh; } set { m_str_s_yonghubh = value; } }

        private decimal? m_dec_i_caozuor;
        /// <summary>
        /// 操作人
        /// </summary>
        public decimal? I_CAOZUOR { get { return m_dec_i_caozuor; } set { m_dec_i_caozuor = value; } }

        private DateTime m_DT_d_caozuorq;
        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime D_CAOZUORQ { get { return m_DT_d_caozuorq; } set { m_DT_d_caozuorq = value; } }

        private decimal m_dec_i_jlzt;
        /// <summary>
        /// 记录状态0正常1删除
        /// </summary>
        public decimal I_JLZT { get { return m_dec_i_jlzt; } set { m_dec_i_jlzt = value; } }
        public S_UPLOAD_LOG()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace BLL.Access
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class S_UPLOAD_LOGProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public S_UPLOAD_LOGProcess() { conn = Platform.Configuration.ConfigHelper.BusinessConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据S_UPLOAD_LOG实体添加或者修改S_UPLOAD_LOG信息
        /// </summary>
        public bool InsertOrUpdate(S_UPLOAD_LOG S_UPLOAD_LOG, OracleTransaction Transaction)
        {
            if (S_UPLOAD_LOG.ID == 0)
            {
                InsertS_UPLOAD_LOG(S_UPLOAD_LOG, Transaction);
            }
            else
            {
                UpdateS_UPLOAD_LOG(S_UPLOAD_LOG, Transaction);
            }
            return S_UPLOAD_LOG.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据S_UPLOAD_LOG实体添加或修改S_UPLOAD_LOG信息
        /// </summary>
        public bool InsertOrUpdate(S_UPLOAD_LOG S_UPLOAD_LOG)
        {
            return InsertOrUpdate(S_UPLOAD_LOG, null);
        }



        /// <summary>
        /// 根据S_UPLOAD_LOG主键删除S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteS_UPLOAD_LOG(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelS_UPLOAD_LOG";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据S_UPLOAD_LOG主键删除S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteS_UPLOAD_LOG(decimal ID)
        {
            return DeleteS_UPLOAD_LOG(ID, null);
        }

        /// <summary>
        /// 根据条件删除S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteS_UPLOAD_LOGsDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelS_UPLOAD_LOGsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteS_UPLOAD_LOGsDynamic(string WhereClause)
        {
            return DeleteS_UPLOAD_LOGsDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据S_UPLOAD_LOG主键选择S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>S_UPLOAD_LOG信息</returns>
        public S_UPLOAD_LOG SelectS_UPLOAD_LOG(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelS_UPLOAD_LOG";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                S_UPLOAD_LOG S_UPLOAD_LOG = PopulateS_UPLOAD_LOG(rd);
                rd.Close();
                return S_UPLOAD_LOG;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据S_UPLOAD_LOG主键选择S_UPLOAD_LOG信息
        /// </summary>
        /// <returns>S_UPLOAD_LOG信息</returns>
        public S_UPLOAD_LOG SelectS_UPLOAD_LOG(decimal ID)
        {
            return SelectS_UPLOAD_LOG(ID, null);
        }

        /// <summary>
        /// 选择所有S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有S_UPLOAD_LOG信息</returns>
        public DataTable SelectS_UPLOAD_LOGsAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelS_UPLOAD_LOGsAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有S_UPLOAD_LOG信息
        /// </summary>
        /// <returns>所有S_UPLOAD_LOG信息</returns>
        public DataTable SelectS_UPLOAD_LOGsAll()
        {
            return SelectS_UPLOAD_LOGsAll(null);
        }

        /// <summary>
        /// 根据条件选择S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>S_UPLOAD_LOG信息</returns>
        public DataTable SelectS_UPLOAD_LOGsDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelS_UPLOAD_LOGsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>S_UPLOAD_LOG信息</returns>
        public DataTable SelectS_UPLOAD_LOGsDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectS_UPLOAD_LOGsDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>S_UPLOAD_LOG信息</returns>
        public DataTable SelectS_UPLOAD_LOGsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelS_UPLOAD_LOGsDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择S_UPLOAD_LOG信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>S_UPLOAD_LOG信息</returns>
        public DataTable SelectS_UPLOAD_LOGsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectS_UPLOAD_LOGsDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新S_UPLOAD_LOG字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateS_UPLOAD_LOGsDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdS_UPLOAD_LOGDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新S_UPLOAD_LOG字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateS_UPLOAD_LOGsDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateS_UPLOAD_LOGsDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertS_UPLOAD_LOG(S_UPLOAD_LOG S_UPLOAD_LOG, OracleTransaction Transaction)
        {
            string spName = "CS_InsS_UPLOAD_LOG";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = S_UPLOAD_LOG.I_TYPE;
            storedParams[1].Value = S_UPLOAD_LOG.S_WENJIANLJ;
            storedParams[2].Value = S_UPLOAD_LOG.I_WENJIANLX;
            storedParams[3].Value = S_UPLOAD_LOG.S_WENJIANMC;
            storedParams[4].Value = S_UPLOAD_LOG.S_YONGHUBH;
            storedParams[5].Value = S_UPLOAD_LOG.I_CAOZUOR;
            storedParams[6].Value = S_UPLOAD_LOG.D_CAOZUORQ;
            storedParams[7].Value = S_UPLOAD_LOG.I_JLZT;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            S_UPLOAD_LOG.ID = Convert.ToInt32(storedParams[8].Value);
            return result;
        }
        private bool UpdateS_UPLOAD_LOG(S_UPLOAD_LOG S_UPLOAD_LOG, OracleTransaction Transaction)
        {
            string spName = "CS_UpdS_UPLOAD_LOG";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = S_UPLOAD_LOG.I_TYPE;
            storedParams[1].Value = S_UPLOAD_LOG.S_WENJIANLJ;
            storedParams[2].Value = S_UPLOAD_LOG.I_WENJIANLX;
            storedParams[3].Value = S_UPLOAD_LOG.S_WENJIANMC;
            storedParams[4].Value = S_UPLOAD_LOG.S_YONGHUBH;
            storedParams[5].Value = S_UPLOAD_LOG.I_CAOZUOR;
            storedParams[6].Value = S_UPLOAD_LOG.D_CAOZUORQ;
            storedParams[7].Value = S_UPLOAD_LOG.I_JLZT;
            storedParams[8].Value = S_UPLOAD_LOG.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private S_UPLOAD_LOG PopulateS_UPLOAD_LOG(IDataReader dr)
        {
            S_UPLOAD_LOG S_UPLOAD_LOG = new S_UPLOAD_LOG();
            S_UPLOAD_LOG.ID = dr["ID"] == DBNull.Value ? (decimal)0 : (decimal)dr["ID"];
            S_UPLOAD_LOG.I_TYPE = dr["I_TYPE"] == DBNull.Value ? null : (decimal?)dr["I_TYPE"];
            S_UPLOAD_LOG.S_WENJIANLJ = dr["S_WENJIANLJ"] == DBNull.Value ? null : (string)dr["S_WENJIANLJ"];
            S_UPLOAD_LOG.I_WENJIANLX = dr["I_WENJIANLX"] == DBNull.Value ? null : (decimal?)dr["I_WENJIANLX"];
            S_UPLOAD_LOG.S_WENJIANMC = dr["S_WENJIANMC"] == DBNull.Value ? null : (string)dr["S_WENJIANMC"];
            S_UPLOAD_LOG.S_YONGHUBH = dr["S_YONGHUBH"] == DBNull.Value ? null : (string)dr["S_YONGHUBH"];
            S_UPLOAD_LOG.I_CAOZUOR = dr["I_CAOZUOR"] == DBNull.Value ? null : (decimal?)dr["I_CAOZUOR"];
            S_UPLOAD_LOG.D_CAOZUORQ = dr["D_CAOZUORQ"] == DBNull.Value ? Convert.ToDateTime("1900-1-1") : (DateTime)dr["D_CAOZUORQ"];
            S_UPLOAD_LOG.I_JLZT = dr["I_JLZT"] == DBNull.Value ? (decimal)0 : (decimal)dr["I_JLZT"];
            return S_UPLOAD_LOG;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion